//
//  operator_overload.hpp
//  learnC++
//
//  Created by liuzhibing on 2018/6/9.
//  Copyright © 2018年 yunfan.com. All rights reserved.
//

#ifndef operator_overload_hpp
#define operator_overload_hpp

#include <stdio.h>
#include <iostream>

class OperatorOverload {
    
private:
    int m_value;
    
    
public:
    explicit OperatorOverload(int value);
    
    //重载2元运算符+、-
    friend OperatorOverload operator+(const OperatorOverload &ov1,const OperatorOverload &ov2);
    friend OperatorOverload operator-(const OperatorOverload &ov1,const OperatorOverload &ov2);
    
    //重载1元运算符+、-
    OperatorOverload operator+() const;
    OperatorOverload operator-() const;
    
    //重载<<
    friend std::ostream &operator<<(std::ostream &out,const OperatorOverload &ov);
    
    //重载=
    OperatorOverload &operator=(const OperatorOverload &ov);
    
    //复制构造函数
    OperatorOverload(const OperatorOverload &ov);
    
    //[]
    int operator[](int index);
    
    //()
    int & operator()(int row,int col);
    
    //+=
    OperatorOverload &operator+=(int value);
    
    //类型转换
    operator int() const;
    
    template <class T,class NameT>
    T invoke(int a1,const NameT& name){
        std::cout << name << std::endl;
        return 10;
    }
    
};




#endif /* operator_overload_hpp */
